﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace LotteCinema.Admin
{
    public partial class GiaNiemYet : System.Web.UI.Page
    {
        BUS.BGiaNiemYet bgny = new BUS.BGiaNiemYet();
        static string magny;
        static int tien;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                HienThiGiaNiemYet();
                pncapnhat.Visible = false;
            }
        }
        public void HienThiGiaNiemYet()
        {
            grdGiaNiemYet.DataSource = bgny.GIANIEMYET_LietKe();
            grdGiaNiemYet.DataBind();
        }
        protected void grdGiaNiemYet_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            magny = e.CommandArgument.ToString();
            if (e.CommandName == "Edit")
            {
                txttien.Text = e.Item.Cells[3].Text;
                pnthongtin.Visible = false;
                pncapnhat.Visible = true;
            }
        }

        protected void lblCapNhatGNY_Click(object sender, EventArgs e)
        {
            try
            {
                tien = int.Parse(txttien.Text);
                bgny.GIANIEMYET_capnhat(magny, tien);
                DTO.WebMegBox.Show("Cập nhật thành công");
                HienThiGiaNiemYet();
                pnthongtin.Visible=true;
                pncapnhat.Visible=false;
            }
            catch (Exception ex)
            {
                DTO.WebMegBox.Show("Cập nhật không thành công");
            }

        }

        protected void lblQuayLai2_Click(object sender, EventArgs e)
        {
            pnthongtin.Visible = true;
            pncapnhat.Visible = false;
        }
    }
}